<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2021/9/14
  Time: 15:25
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@page isELIgnored="false" %>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<html>
<head>
    <%
        pageContext.setAttribute("APP_PATH",request.getContextPath());
    %>
    <meta charset="UTF-8">
    <title>ERP系统 - 合同信息管理</title>
    <link rel="stylesheet" href="${APP_PATH}/static/css/main.css">
    <link rel="stylesheet" href="${APP_PATH}/static/lib/font-awesome/css/font-awesome.css">
</head>
<body>
    <h3>合同信息管理</h3>
    <div class="actions">
        <div>
            <shiro:hasPermission name="sys:contract:add">
                <a class="btn btn-primary" href="${APP_PATH}/contract/jumpToAdd">添加合同信息</a>&nbsp;&nbsp;
            </shiro:hasPermission>


        </div>
        <shiro:hasPermission name="sys:contract:select">
            <form method="post" action="${APP_PATH}/contract/search">
                <select name="field">
                    <option value="cId">合同编号</option>
                    <option value="hId">合同房子序号</option>
                    <option value="lId">合同租户序号</option>
                </select>
                <input type="text"  name="" placeholder="输入关键字查询" value="${sessionScope.selKeyword.lId == null ?  (sessionScope.selKeyword.cId == null ?  (sessionScope.selKeyword.hId == null ?  '':sessionScope.selKeyword.hId) :sessionScope.selKeyword.cId ):sessionScope.selKeyword.lId }">
                <input type="submit" id="select" value="搜索">
            </form>
        </shiro:hasPermission>

    </div>

    <table class="list">
        <tr>
            <th>合同编号</th>
            <th>合同房子序号</th>
            <th>合同房子地址</th>
            <th>合同房子面积</th>
            <th>合同租户序号</th>
            <th>合同租户姓名</th>
            <th>合同租户手机号</th>
            <th>合同租户身份证号</th>
            <th>合同签订时间</th>
            <th>合同生效时间</th>
            <th>合同失效时间</th>

            <th>操作</th>

        </tr>
        <c:forEach var="contract" items="${contractMsg.list}" varStatus="status">
            <c:if test="${contract.cStatus==1}">
                <tr>
                    <td>${contract.cId}</td>
                    <td>${contract.hId}</td>
                    <td>${contract.house.hAddress}</td>
                    <td>${contract.house.hArea}</td>
                    <td>${contract.lId}</td>
                    <td>${contract.lessee.lName}</td>
                    <td>${contract.lessee.lTel}</td>
                    <td>${contract.lessee.lIdcard}</td>
                    <td>${contract.cTime}</td>
                    <td>${contract.cTaketime}</td>
                    <td>${contract.cOvertime}</td>
                    <td>
                        <a id="xiang" class="fa fa-info" title="详情" href="${APP_PATH}/contract/detail?cid=${contract.cId}">详情</a>
                        &nbsp;<shiro:hasPermission name="sys:contract:update">
                        <a class="fa fa-pencil" title="编辑" href="${APP_PATH}/contract/update?cid=${contract.cId}">编辑</a>
                    </shiro:hasPermission>
                        <shiro:hasPermission name="sys:contract:delete">
                            <a class="fa fa-remove" title="删除" href="${APP_PATH}/contract/delete?cid=${contract.cId}" onclick="return confirmDelete()">删除</a>
                        </shiro:hasPermission>
                        &nbsp;

                    </td>
                </tr>
            </c:if>
        </c:forEach>

    </table>
    <div class="pager-info">
        <div>共有 ${contractMsg.total} 条记录，第 ${contractMsg.pageNum}/${contractMsg.pages} 页 </div>
        <div>
            <ul class="pagination">
                <li class="paginate_button previous disabled }">
                    <a href="${APP_PATH}/contract/msg?pn=${contractMsg.hasPreviousPage ? contractMsg.prePage:1}">上一页</a>
                </li>
                <c:forEach begin="1" end="${contractMsg.pages}"  var="page">
                    <li class="${contractMsg.pageNum == page?'paginate_button active':''}"><a href="${APP_PATH}/contract/msg?pn=${page}">${page}</a></li>
                </c:forEach>
                <li class="paginate_button next disabled">
                    <a href="${APP_PATH}/contract/msg?pn=${contractMsg.hasNextPage ? contractMsg.nextPage:contractMsg.pages}">下一页</a>
                </li>
            </ul>
        </div>
    </div>
    <script src="${APP_PATH}/static/lib/jquery/jquery.js"></script>
    <script>
        function confirmDelete(){
           return confirm("确定要删除吗？");
        }
        $("#select").click(function (){
            var val = $("select[name=field]").val();
            $(this).prev().attr("name",val);
        })


            if(${sessionScope.deleteMsg != null}){
                alert("${sessionScope.deleteMsg}");
            }else if(${sessionScope.updateMsg != null}){
                alert("${sessionScope.updateMsg}");

            }else if(${sessionScope.addMsg != null}){
                alert("${sessionScope.addMsg}");
            }
            <%
            session.removeAttribute("deleteMsg");
            session.removeAttribute("updateMsg");
            session.removeAttribute("addMsg");
            %>

    </script>
</body>
</html>
